package de.tsystems.dict.webservice;

import de.tsystems.dict.api.LanguageService;
import de.tsystems.dict.model.Language;
import org.springframework.transaction.annotation.Transactional;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.Provider;
import java.util.List;

@Provider
@Path("/languages")
@Produces({MediaType.APPLICATION_JSON})
public interface LanguageManipulationService {

    LanguageService getLanguageService();

    void setLanguageService(LanguageService languageService);

    @GET
    @Produces("text/plain")
    @Transactional(readOnly = true)
    String greetUser();

    @GET
    @Path("/size")
    @Produces("text/plain")
    @Transactional(readOnly = true)
    String size();

    @POST
    @Produces("text/plain")
    @Consumes("application/json")
    @Transactional
    @Path("/create")
    String create(LanguageInfo info);

    @GET
    @Path("/list")
    @Produces("application/json")
    @Transactional(readOnly = true)
    List<Language> list();


    public static class LanguageInfo {
        private String id;
        private String name;

        public LanguageInfo() {}

        public LanguageInfo(String id, String name) {
            this.id = id;
            this.name = name;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

    }
}
